<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/tablibs.jsp"%>
<!-- footer content -->
<footer>
	<div class="pull-right">
		${title }&nbsp;&nbsp;&nbsp;
	</div>
	<div class="clearfix"></div>
</footer>
<!-- /footer content -->


<div class="modal fade" id="changepwd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
	<div class="modal-dialog" >
		<div class="modal-content">
			<div class="modal-header">
				<h3 class="modal-title" id="myModalLabel" align="center">
					修改密码
				</h3>
			</div>
			<div class="modal-body">
				<div class="row">
					<div class="col-md-12 form-group " align="center">
						<label style="font-size: 18px;text-align: right;" class="control-label col-md-3 col-sm-3 col-xs-12">旧密码：</label>
						<input style="width: 200px;" class="form-control" id="oldpassword" type="password">
					</div>
					<div class="col-md-12 form-group " align="center">
						<label style="font-size: 18px;text-align: right;" class="control-label col-md-3 col-sm-3 col-xs-12">新密码：</label>
						<input style="width: 200px;" class="form-control" id="newpassword" type="password">
					</div>
					<div class="col-md-12 form-group " align="center">
						<label style="font-size: 18px;text-align: right;" class="control-label col-md-3 col-sm-3 col-xs-12">重复新密码：</label>
						<input style="width: 200px;" class="form-control" id="repassword" type="password">
					</div>
					<div class="col-md-12 form-group " align="center">
						<a style="color: #FF5555;font-family: 微软雅黑;" id="changepwdmsg"></a>
					</div>
				</div>				
			</div>
			<div class="modal-footer">
				<p align="center">
					<button type="button" class="btn btn-warning" onclick="savenewpsd();" style="width: 100px">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
		       		<button type="button" class="btn btn-warning" onclick="cannewpsd();" style="width: 100px">取消</button>
				</p>
			</div>
		</div>
	</div>
</div>
<script src="${ctx }/public/js/dic.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx }/public/js/jquery.base64.js"></script>
<script type="text/javascript">
	function changePwd() {
		$('#changepwd').modal({
			backdrop : 'static',
			keyboard : false
		});
	}
	function cannewpsd() {
		$('#changepwd').modal('hide');
		$('#changepwdmsg').html('');
	}
	function savenewpsd() {
		var oldpassword = $("#oldpassword").val();
		var newpassword = $("#newpassword").val();
		var repassword = $("#repassword").val();
		if (oldpassword == '' || oldpassword == null) {
			$('#changepwdmsg').html('请输入旧密码！');
			return;
		}
		if (newpassword == '' || newpassword == null) {
			$('#changepwdmsg').html('请输入新密码！');
			return;
		}
		if (repassword == '' || repassword == null) {
			$('#changepwdmsg').html('请再次输入新密码！');
			return;
		}
		if (repassword != newpassword) {
			$('#changepwdmsg').html('两次密码输入不同！');
			return;
		}
		$.ajax({
			type : 'POST',
			url : "${ctx}/changePsd",
			data:{
				oldpwd:oldpassword,
				newpwd:newpassword
			},
			success:function(data){
				if(data=='0'){
					$('#changepwdmsg').html('登录过期，请重新登录！');
				}
				if(data=='1'){
					alert("修改成功");
					cannewpsd();
				}
				if(data=='2'){
					$('#changepwdmsg').html('密码输入错误！');
				}
			}
		});
	}
</script>